package com.aoxin.controller.system;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aoxin.mapper.SlfChildExpectedTimeMapper;
import com.aoxin.mapper.SlfChildrenBindingPackageMapper;
import com.aoxin.mapper.SlfClassroomClassMapper;
import com.aoxin.mapper.SlfClassroomEmployMapper;
import com.aoxin.mapper.SlfUserCourseConditionMapper;
import com.aoxin.mapper.course.systemCourse.SchoolCourseDao;
import com.aoxin.mapper.opm.SlfClassroomMapper;
import com.aoxin.model.SlfChildrenBindingPackage;
import com.aoxin.model.SlfClassroomCEmployee;
import com.aoxin.model.SlfClassroomClass;
import com.aoxin.model.SlfClassroomEmploy;
import com.aoxin.model.SlfUserCourseCondition;
import com.aoxin.model.course.SchoolCourse;
import com.aoxin.model.opm.SlfClassroom;
import com.aoxin.util.AjaxRes;
import com.aoxin.util.Const;
import com.aoxin.util.DateWay;
import com.aoxin.util.enumerate.OperateType;
import com.aoxin.util.log.LogInfo;

@Controller
@RequestMapping("/web")
@ResponseBody
public class HandMovementWrokController {
	@Autowired
	SlfChildrenBindingPackageMapper slfChildrenBindingPackageMapper;
	@Autowired
	private SchoolCourseDao schoolCourseMapper;
	@Autowired
	SlfClassroomClassMapper slfClassroomClassMapper;
	@Autowired
	private SlfClassroomMapper slfClassroomMapper;
	@Autowired
	private SlfUserCourseConditionMapper slfUserCourseConditionMapper;
	@Autowired
	private SlfChildExpectedTimeMapper slfChildExpectedTimeMapper;
	@Autowired
	private SlfClassroomEmployMapper slfClassroomEmployMapper;
	
	/**
	 * 绑定包页面查询
	 * 
	 * @param SlfChildrenBindingPackage slfChildrenBindingPackage
	 *           
	 * @return List<SlfChildrenBindingPackage>
	 */
	   @RequestMapping("/queryChildrenBindingPackage")
	   public AjaxRes queryChildrenBindingPackage(AjaxRes ajaxRes,SlfChildrenBindingPackage slfChildrenBindingPackage){
		   try {
			   slfChildrenBindingPackage.setState(0);
			   List<SlfChildrenBindingPackage> slfChildrenBindingPackages = slfChildrenBindingPackageMapper.queryChildrenBindingPackageMapper(slfChildrenBindingPackage);
	            ajaxRes.setSucceed(slfChildrenBindingPackages,Const.SUCCESS);
	        } catch (Exception e) {
	        	ajaxRes.setFailMsg(e.getMessage());
	            e.printStackTrace();
	        }
	        return ajaxRes;
	   }
	   
	    /**
		 * 绑定包页面查询
		 * 
		 * @param SlfChildrenBindingPackage slfChildrenBindingPackage
		 *           
		 * @return List<SlfChildrenBindingPackage>
		 */
		   @RequestMapping("/queryChildrenBindingPackageOthers")
		   public AjaxRes queryChildrenBindingPackageOther(AjaxRes ajaxRes,SlfChildrenBindingPackage slfChildrenBindingPackage){
			   try {
				   List<SlfChildrenBindingPackage> slfChildrenBindingPackages = slfChildrenBindingPackageMapper.queryChildrenBindingPackageOthersMapper(slfChildrenBindingPackage);
		            ajaxRes.setSucceed(slfChildrenBindingPackages,Const.SUCCESS);
		        } catch (Exception e) {
		        	ajaxRes.setFailMsg(e.getMessage());
		            e.printStackTrace();
		        }
		        return ajaxRes;
		   }
	   
	    /**
		 * 绑定包页面查询
		 * 
		 * @param SlfChildrenBindingPackage slfChildrenBindingPackage
		 *           
		 * @return List<SlfChildrenBindingPackage>
		 */
		   @RequestMapping("/queryChlidrenInformation")
		   public AjaxRes queryChlidrenInformation(AjaxRes ajaxRes,String phone){
			   try {
				   List<SlfChildrenBindingPackage> slfChildrenBindingPackages = slfChildrenBindingPackageMapper.queryChlidrenInformationMapper(phone);
		            ajaxRes.setSucceed(slfChildrenBindingPackages,Const.SUCCESS);
		        } catch (Exception e) {
		        	ajaxRes.setFailMsg(e.getMessage());
		            e.printStackTrace();
		        }
		        return ajaxRes;
		   }
	
	    /**
		 * 绑定购买包
		 * 
		 * @param SlfChildrenBindingPackage slfChildrenBindingPackage
		 *           
		 * @return SUCC
		 */
	   @RequestMapping("/insertChildrenBindingPackage")
	   @Transactional
	   public AjaxRes insertChildrenBindingPackage(AjaxRes ajaxRes,SlfChildrenBindingPackage slfChildrenBindingPackage){
		   try {
			    //增加该课程包第一条课程
		    	SchoolCourse schoolCourse = schoolCourseMapper.getPageCourseLimitOne(slfChildrenBindingPackage.getBuyPackageId());
		    	slfChildrenBindingPackage.setCourseId(schoolCourse.getCourseId());
		    	slfChildrenBindingPackage.setCourseName(schoolCourse.getName());
	            this.slfChildrenBindingPackageMapper.insertSelective(slfChildrenBindingPackage);
	            ajaxRes.setSucceed(Const.SUCCESS);
	        } catch (Exception e) {
	        	ajaxRes.setFailMsg(e.getMessage());
	            e.printStackTrace();
	        }
	        return ajaxRes;
	   }
	   
	    /**
		 * 修改绑定购买包(*已被组建班级的无法再修改)
		 * 
		 * @param SlfChildrenBindingPackage slfChildrenBindingPackage
		 *           
		 * @return SUCC
		 */
	   @RequestMapping("/updateChildrenBindingPackage")
	   public AjaxRes updateChildrenBindingPackage(AjaxRes ajaxRes,SlfChildrenBindingPackage slfChildrenBindingPackage){
		   try {
			   //增加该课程包第一条课程
		    	SchoolCourse schoolCourse = schoolCourseMapper.getPageCourseLimitOne(slfChildrenBindingPackage.getBuyPackageId());
		    	slfChildrenBindingPackage.setCourseId(schoolCourse.getCourseId());
		    	slfChildrenBindingPackage.setCourseName(schoolCourse.getName());
	            this.slfChildrenBindingPackageMapper.updateByPrimaryKeySelective(slfChildrenBindingPackage);
	            ajaxRes.setSucceed(Const.SUCCESS);
	        } catch (Exception e) {
	        	ajaxRes.setFailMsg(e.getMessage());
	            e.printStackTrace();
	        }
	        return ajaxRes;
	   }
	   
	    /**
		 * 组建班级(判断已绑定班级的用户,state=1时给予换班(除pkState=1已排课)提示*可新增可修改)
		 * 
		 * @param SlfClassroomClass slfClassroomClass,String[] parameter
		 *           
		 * @return SUCC
		 */
	   @RequestMapping("/insertOrganizationClass")
	   @Transactional
	   public AjaxRes insertOrganizationClass(AjaxRes ajaxRes,@RequestParam("parameter")String[] parameter,SlfClassroomClass slfClassroomClass){
		   try {
			    slfClassroomClass.setClassNumber(parameter.length);
			    slfClassroomClassMapper.insertSelective(slfClassroomClass);
			    Map<String,Object> map = new HashMap<String, Object>();
			    map.put("classId",slfClassroomClass.getClassId());
			    map.put("className",slfClassroomClass.getClassName());
			    map.put("list",parameter);
	            this.slfChildrenBindingPackageMapper.updateOrganizationClassMapper(map);
	            ajaxRes.setSucceed(Const.SUCCESS);
	        } catch (Exception e) {
	        	ajaxRes.setFailMsg(e.getMessage());
	            e.printStackTrace();
	        }
	        return ajaxRes;
	   }
	   
	    /**
		 * 查询绑定了教室下所有的包
		 * 
		 * @param Integer classroomId
		 *           
		 * @return List<SlfChildrenBindingPackage>
		 */
		   @RequestMapping("/querySlfClassroomPackage")
		   public AjaxRes querySlfClassroomPackage(AjaxRes ajaxRes,Integer classroomId,Integer coursePageId){
			   try {
				    List<SlfClassroom> slfClassroom = slfClassroomMapper.getSlfClassroomOther(classroomId,coursePageId);
		            ajaxRes.setSucceed(slfClassroom,Const.SUCCESS);
		        } catch (Exception e) {
		        	ajaxRes.setFailMsg(e.getMessage());
		            e.printStackTrace();
		        }
		        return ajaxRes;
		   }
		   
		    /**
			 * 退班
			 * 
			 * @param Integer childrenId,Integer coursePageId,Long slfBindingChildrenId,Integer classId
			 *           
			 * @return SUCC
			 */
		   @RequestMapping("/retire")
		   @Transactional
		   public AjaxRes retire(AjaxRes ajaxRes,Integer childrenId,Integer classId,Integer coursePageId,Long slfBindingChildrenId){
			   try {
				   slfChildrenBindingPackageMapper.updateByPrimaryKeyOther(slfBindingChildrenId);
		           //删除
				   Map<String,Object> map = new HashMap<String, Object>();
				   map.put("chilrenId",childrenId);
				   map.put("coursePageId",coursePageId);
				   map.put("classId",classId);
				   slfUserCourseConditionMapper.retireMapper(map);
				   slfClassroomClassMapper.retireMapper(classId);
				   ajaxRes.setSucceed(Const.SUCCESS);
		        } catch (Exception e) {
		        	ajaxRes.setFailMsg(e.getMessage());
		            e.printStackTrace();
		        }
		        return ajaxRes;
		   }
		   
		   /**
			 * 插班
			 * 
			 * @param Integer childrenId,Integer coursePageId,Long slfBindingChildrenId,Integer classId
			 *           
			 * @return SUCC
			 */
		   @RequestMapping("/joinClass")
		   @Transactional
		   public AjaxRes joinClass(AjaxRes ajaxRes,SlfChildrenBindingPackage slfChildrenBindingPackage){
			   try {
				   if(slfChildrenBindingPackage.getCourseId()==null || "".equals(slfChildrenBindingPackage.getCourseId())){
				   SchoolCourse schoolCourse = schoolCourseMapper.getPageCourseLimitOne(slfChildrenBindingPackage.getBuyPackageId());
			       slfChildrenBindingPackage.setCourseId(schoolCourse.getCourseId());
			       slfChildrenBindingPackage.setCourseName(schoolCourse.getName());
				   }
				   slfChildrenBindingPackage.setState(1);
				   //新增
				   this.slfChildrenBindingPackageMapper.updateByPrimaryKeySelective(slfChildrenBindingPackage);
				   //插班
				   slfClassroomClassMapper.joinClassMapper(slfChildrenBindingPackage.getClassId());
				   ajaxRes.setSucceed(Const.SUCCESS);
		        } catch (Exception e) {
		        	ajaxRes.setFailMsg(e.getMessage());
		            e.printStackTrace();
		        }
		        return ajaxRes;
		   }
		   
	   
	    /**
		 * 查询班级信息(classId,state(是否可排课))
		 * 
		 * @param SlfClassroomClass slfClassroomClass
		 *           
		 * @return 
		 */
	   @RequestMapping("/queryOrganizationClass")
	   @Transactional
	   public AjaxRes queryOrganizationClass(AjaxRes ajaxRes,SlfClassroomClass slfClassroomClass){
		   try {
			   List<SlfClassroomClass> slfClassroomClasss = slfClassroomClassMapper.queryOrganizationClassMapper(slfClassroomClass);
	            ajaxRes.setSucceed(slfClassroomClasss,Const.SUCCESS);
	        }catch (Exception e) {
	        	ajaxRes.setFailMsg(e.getMessage());
	            e.printStackTrace();
	        }
	        return ajaxRes;
	   }
	   
	   /**
		 * 编辑班级信息(主要作用用于更换绑定的教室)
		 * 
		 * @param SlfClassroomClass slfClassroomClass
		 *           
		 * @return SUCC
		 */
	   @RequestMapping("/updateOrganizationClass")
	   @Transactional
	   public AjaxRes updateOrganizationClass(AjaxRes ajaxRes,SlfClassroomClass slfClassroomClass){
		   try {
	            this.slfClassroomClassMapper.updateByPrimaryKeySelective(slfClassroomClass);
	            this.slfChildrenBindingPackageMapper.updateClassMapper(slfClassroomClass);
	            ajaxRes.setSucceed(Const.SUCCESS);
	        } catch (Exception e) {
	        	ajaxRes.setFailMsg(e.getMessage());
	            e.printStackTrace();
	        }
	        return ajaxRes;
	   }
	   
	   
	    /**
		 * 查询班级上课进度(classId,state(是否可排课))*排课可做参考接口进度
		 * 
		 * @param SlfClassroomClass slfClassroomClass
		 *           
		 * @return 
		 */
	   @RequestMapping("/queryCourseSchedule")
	   @Transactional
	   public AjaxRes queryCourseSchedule(AjaxRes ajaxRes,Integer classId,Integer coursePackageId){
		   try {
			    List<SchoolCourse> schoolCourses = schoolCourseMapper.getPageCourse(coursePackageId);
			    List<SlfUserCourseCondition> slfUserCourseConditions = slfUserCourseConditionMapper.queryCourseScheduleMapper(classId);
				List<SchoolCourse> newSchoolCourse = schoolCourses.subList(slfUserCourseConditions.size(),schoolCourses.size());
				for(int i = 0;i < newSchoolCourse.size();i++){
				SlfUserCourseCondition SlfUserCourseCondition = new SlfUserCourseCondition();
				SlfUserCourseCondition.setCourseId(newSchoolCourse.get(i).getCourseId());
				SlfUserCourseCondition.setCourse(newSchoolCourse.get(i).getName());
				SlfUserCourseCondition.setFlag(2);
				slfUserCourseConditions.add(SlfUserCourseCondition);
				}
			    ajaxRes.setSucceed(slfUserCourseConditions,Const.SUCCESS);
	        }catch (Exception e) {
	        	ajaxRes.setFailMsg(e.getMessage());
	            e.printStackTrace();
	       }
	        return ajaxRes;
	   }
	   
	    /**
		 * 手动排课人物信息(排课时期望时间参考)
		 * 
		 * @param Integer classId
		 *           
		 * @return SUCC
		 */
	   @RequestMapping("/expectTimeReferTo")
	   @Transactional
	   public AjaxRes expectTimeReferTo(AjaxRes ajaxRes,Integer classId){
		   try {
			List<String> childrenIds = slfChildrenBindingPackageMapper.queryClassChildrenOtherMapper(classId);
			Map<String,Object> map = new HashMap<String, Object>();
			map.put("list",childrenIds);
			List<SlfChildrenBindingPackage> slfChildrenBindingPackage = new ArrayList<SlfChildrenBindingPackage>();
			if(childrenIds.size()>0){
			slfChildrenBindingPackage = slfChildrenBindingPackageMapper.queryChildrenBindingPackageOtherMapper(map);
			}
			ajaxRes.setSucceed(slfChildrenBindingPackage,Const.SUCCESS);
		   }catch (Exception e) {
	        	ajaxRes.setFailMsg(e.getMessage());
	            e.printStackTrace();
	       }
	        return ajaxRes;
	   }
	   
	    /**
		 * 手动排课人物信息(教室被占用时间参考)
		 * 
		 * @param Integer classroomId
		 *           
		 * @return SUCC
		 */
	   @RequestMapping("/employTimeReferTo")
	   public AjaxRes employTimeReferTo(AjaxRes ajaxRes,Integer classroomId,String time,String week,Integer classId){
		   try {
			   week = "周" + week;
 			   Map<String,Object> map = new HashMap<String, Object>();
 			   map.put("classroomId",classroomId);
 			   map.put("employTime",week);
 			   map.put("courseTime", time);
			   List<SlfClassroomEmploy> SlfClassroomEmploys = slfClassroomEmployMapper.queryEmployWeekMapper(map);
			   for(int i = 0;i<SlfClassroomEmploys.size();i++){
			   SlfClassroomEmploys.get(i).setClassType(SlfClassroomEmploys.get(i).getClassName());
			   }
			   List<SlfClassroomCEmployee> SlfClassroomCEmployees = slfClassroomEmployMapper.queryEmployWeekCMapper(map);
			   for(int i=0;i<SlfClassroomCEmployees.size();i++){
			   SlfClassroomEmploy slfClassroomEmploy = new  SlfClassroomEmploy();
			   SlfClassroomCEmployees.get(i).getCourseName();
			   slfClassroomEmploy.setClassType("c类课");
			   slfClassroomEmploy.setEmployTime(SlfClassroomCEmployees.get(i).getCourseTime());
			   SlfClassroomEmploys.add(slfClassroomEmploy);
			   }
			   String[] times = Const.TIMESECTION;
			   List<String> list1 = Arrays.asList(times);
			   List<String> list = new ArrayList<String>();
			   for(int i = 0;i<SlfClassroomEmploys.size();i++){
			   String s = SlfClassroomEmploys.get(i).getEmployTime().substring((SlfClassroomEmploys.get(i).getEmployTime().lastIndexOf(",")+1),SlfClassroomEmploys.get(i).getEmployTime().length());
			   SlfClassroomEmploys.get(i).setEmployTime(s);
			   list.add(s);
			   }
			  //list1.removeAll(list);
		       String temp2 = list.toString ().replaceAll ("[\\[\\]]", ",").replaceAll ("\\s+", "");
		       String result2 = "";
		       for ( int i = 0; i < list1.size (); i++ )
		        {
		            if (temp2.indexOf ("," + list1.get (i) + ",") == -1)
		            {
		                result2 += list1.get (i) + ",";
		            }
		        }
		       String[] li = result2.split(",");
			   for(String pt : li){
			   SlfClassroomEmploy slfClassroomEmploy = new  SlfClassroomEmploy();
			   slfClassroomEmploy.setEmployTime(pt);
			   slfClassroomEmploy.setClassType("");
			   SlfClassroomEmploys.add(slfClassroomEmploy);
			   }
			   for(int i = 0;i<SlfClassroomEmploys.size();i++){
			   if(SlfClassroomEmploys.get(i).getEmployTime().equals("9:00-10:00")){
				  SlfClassroomEmploys.get(i).setSort(1);
			   }else if(SlfClassroomEmploys.get(i).getEmployTime().equals("10:00-11:00")){
				  SlfClassroomEmploys.get(i).setSort(2);
			   }else if(SlfClassroomEmploys.get(i).getEmployTime().equals("11:00-12:00")){
				  SlfClassroomEmploys.get(i).setSort(3);
			   }else if(SlfClassroomEmploys.get(i).getEmployTime().equals("14:00-15:00")){
				  SlfClassroomEmploys.get(i).setSort(4);
			   }else if(SlfClassroomEmploys.get(i).getEmployTime().equals("15:00-16:00")){
				  SlfClassroomEmploys.get(i).setSort(5);
		 	   }else if(SlfClassroomEmploys.get(i).getEmployTime().equals("16:00-17:00")){
				  SlfClassroomEmploys.get(i).setSort(6);
			   }else if(SlfClassroomEmploys.get(i).getEmployTime().equals("17:00-18:00")){
				  SlfClassroomEmploys.get(i).setSort(7);
			   }else if(SlfClassroomEmploys.get(i).getEmployTime().equals("19:00-20:00")){
				  SlfClassroomEmploys.get(i).setSort(8);
			   }else if(SlfClassroomEmploys.get(i).getEmployTime().equals("20:00-21:00")){
				  SlfClassroomEmploys.get(i).setSort(9);
			   }
			   }
			   //排序(倒序)
			   SlfClassroomEmploys.sort(new Comparator<SlfClassroomEmploy>() {//Comparator 比较器. 需要实现比较方法
		        @Override
		        public int compare(SlfClassroomEmploy o1, SlfClassroomEmploy o2) {
		            return o1.getSort()-o2.getSort();//从大到小
		        }
		        });   
			    ajaxRes.setSucceed(SlfClassroomEmploys,Const.SUCCESS);
		   }catch (Exception e) {
	        	ajaxRes.setFailMsg(e.getMessage());
	            e.printStackTrace();
	       }
	        return ajaxRes;
	   }
	   
	    /**
		 * 手动排课(当离最好上课时间距离3天时，前端控制不能让管理员再去操作,state=1)
		 * 
		 * @param String time,Integer classId,SlfUserCourseCondition slfUserCourseCondition(classrooomId,classroomName,courseId,course,courseBackageId,state)
		 *           
		 * @return SUCC
		 */
	   @RequestMapping("/handMovementTeachingSchedule")
	   @Transactional
	   public AjaxRes handMovementTeachingSchedule(AjaxRes ajaxRes,Integer classroomId,Integer state,Integer employNum,String time,Integer classId,SlfUserCourseCondition slfUserCourseCondition){
		   try {
			    Map<String,Object> map = new HashMap<String, Object>();
			    if(state == 0){
		    	String timeOne = time.substring(0, time.indexOf("/"));
			    String timeTwo = time.substring(time.indexOf("/")+1, time.length());
			    String timed = timeTwo.substring(timeTwo.indexOf("-")+1, timeTwo.length());
			    String empTime = GetStartTime(timeOne) + "," + timeTwo;
			    String endTime = timeOne+" "+timed+":00";
			    List<SlfChildrenBindingPackage> childrenIds = slfChildrenBindingPackageMapper.queryClassChildrenMapper(classId);
			   //slfChildExpectedTimeMapper
			    map.put("expectedTime",empTime);
			    map.put("endTime",endTime);
			    map.put("classId",classId);
			    map.put("flag",1);
			    //手动被占用
			    map.put("state",2);
			    //占用时间
			    slfChildExpectedTimeMapper.updateExpectedTime(map);
			    //教室占用
			    SlfClassroomEmploy slfClassroomEmploy = new SlfClassroomEmploy();
			    slfClassroomEmploy.setClassroomId(classroomId);
			    slfClassroomEmploy.setEmployTime(empTime);
			    slfClassroomEmploy.setEmployNum(employNum);
			    slfClassroomEmploy.setEndTime(endTime);
			    slfClassroomEmploy.setClassId(classId);
			    slfClassroomEmploy.setFlag(1);
			    slfClassroomEmploy.setType(0);
			    slfClassroomEmployMapper.insertSelective(slfClassroomEmploy);
			    //课程表
			    for(int i=0;i < childrenIds.size();i++){
		    	slfUserCourseCondition.setUserId(childrenIds.get(i).getChildrenId());
		    	slfUserCourseCondition.setUserName(childrenIds.get(i).getChildrenName());
		    	slfUserCourseCondition.setCourseId(childrenIds.get(i).getCourseId());
		    	slfUserCourseCondition.setCourse(childrenIds.get(i).getCourseName());
		    	slfUserCourseCondition.setEmployTime(endTime);
		    	slfUserCourseCondition.setExpectTime(empTime);
		    	slfUserCourseCondition.setFlag(0);
		    	slfUserCourseCondition.setEmployFlag(0);
		    	slfUserCourseCondition.setCourseType(1);
		    	slfUserCourseCondition.setState(2);
		    	slfUserCourseCondition.setClassrooomId(classroomId);
		    	slfUserCourseCondition.setSchoolId("2");
		    	slfUserCourseConditionMapper.insertSelective(slfUserCourseCondition);
			    }
			    //更新班级上课情况
			    SlfClassroomClass slfClassroomClass = new SlfClassroomClass();
			    slfClassroomClass.setEndAttendClass(endTime);
			    slfClassroomClass.setClassId(classId);
			    slfClassroomClass.setState("1");
			    slfClassroomClassMapper.updateByPrimaryKeySelective(slfClassroomClass);
			    }else{
			    map.put("classId",classId);
			    map.put("flag",0);
			    //手动被占用
			    map.put("state",2);
			    //重置期望时间占用表
			    slfChildExpectedTimeMapper.updateExpectedTimeOther(map);
			    //重置教室绑定班级状态
			    map.put("classroomId",slfUserCourseCondition.getClassroomId());
			    slfClassroomEmployMapper.resettingMapper(map);
			    //重置该班的课程表
			    slfUserCourseConditionMapper.resettingMapper(map);
			//  map.put("expectedTime",empTime);
			//  map.put("endTime",endTime);
			//  map.put("flag",1);
			    SlfClassroomClass slfClassroomClass = new SlfClassroomClass();
			    slfClassroomClass.setClassId(classId);
			    slfClassroomClass.setState("0");
			    slfClassroomClass.setEndAttendClass(null);
			    slfClassroomClassMapper.updateByPrimaryKeySelective(slfClassroomClass);
			     }
			    ajaxRes.setSucceed(Const.SUCCESS);
	        }catch (Exception e) {
	        	ajaxRes.setFailMsg(e.getMessage());
	            e.printStackTrace();
	       }
	        return ajaxRes;
	   }
	   private String GetStartTime(String Time){
		   Integer weekDay = DateWay.getDayofweek(Time);
		   //1是星期日、2是星期一、3是星期二、4是星期三、5是星期四、6是星期五、7是星期六 
		   if(weekDay == 1){
			   weekDay = 7;
		   }else if(weekDay == 7){
			   weekDay = 6;
		   }else if(weekDay == 6){
			   weekDay = 5;
		   }else if(weekDay == 5){
			   weekDay = 4;
		   }else if(weekDay == 4){
			   weekDay = 3;
		   }else if(weekDay == 3){
			   weekDay = 2;
		   }else if(weekDay == 2){
			   weekDay = 1;
		   }
		   String week = DateWay.WeekDayOther(weekDay);
		   return week;
	   }
	   
	   /**
		 * 定时器,修改班级状态
		 * 
		 * @param Integer classroomId
		 *           
		 * @return SUCC
		 */
	   @Scheduled(cron = "0/30 * * * * *") 
//	   @LogInfo(content = "更新班级状态", operateType = OperateType.UPDATE)
	   public void updateState(){
		   //修改班级state状态(表示现在是否可以改变小孩的孩子绑定班级)
		   
		   //修改每个孩子的即将学习的课程
		   
	   }
}
